package com.charlotte.study.gupao.prototype.shallow;


import java.util.ArrayList;
import java.util.List;

/**
 * @author junjie.ding
 * @date 2020/3/2
 */
public class main {
    public static void main(String[] args) {
        ConcretePrototype prototype = new ConcretePrototype();
        prototype.setName("zhangsan");
        prototype.setAge(18);

        List<String> hobbies = new ArrayList<String>();
        hobbies.add("书法");
        hobbies.add("game");
        prototype.setHobbies(hobbies);


        System.out.println("1.被拷贝前：\r\n" + prototype);

        ConcretePrototype clone = prototype.clone();


        System.out.println("2.原始对象被拷贝后：\n" + prototype);
        System.out.println("2.克隆对象：\n" + clone);

        hobbies.add("电脑");

        System.out.println("3.原始对象的兴趣爱好增加新值后：\n" + prototype);
        System.out.println("3.克隆对象：\n" + clone);

        clone.setHobbies(hobbies);

        System.out.println("4.克隆对象对兴趣爱好重新赋值后：\n" + prototype);
        System.out.println("4.克隆对象：\n" + clone);

    }
}
